﻿namespace Sustainalytics.Caching.L
{
    public abstract class L1Cache
    {
        protected IAppCache Cache { get; private set; }

        protected IL2Cache L2Cache { get; private set; }

        protected AppProxyCache L1L2Proxy { get; private set; }


        public L1Cache(IAppCache cache, IL2Cache l2Cache)
        {
            if (cache == null)
            {
                throw new L1AppCacheNullException();
            }

            this.Cache = cache;
            this.L2Cache = l2Cache;

            // push any incoming data from L2 to L1
            this.L2Cache.PushToCache(this.Cache);

            // create proxy cache => links L1 with L2
            this.L1L2Proxy = this.L2Cache.CreateProxyCache(this.Cache);
        }
    }
}
